function m2 = calc_m2(s)
slope = [diff(s.h,1,2),s.h(:,1)-s.h(:,end)]/s.site_width;

nx = length(s.x);
ny = length(s.y);

m2 = sum(sum(slope.^2))/(nx*ny);